﻿using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;

namespace Coway.Ordering.Products
{
    public class ProductAppService : CrudAppService<
        Product,
        ProductDto,
        Guid,
        PagedAndSortedResultRequestDto,
        CreateUpdateProductDto>,
    IProductAppService
    {
        public ProductAppService(IRepository<Product, Guid> repository)
            : base(repository)
        {
        }

        /// <summary>
        /// 获取所有商品信息
        /// </summary>
        /// <returns></returns>
        [Route("api/app/product/allproducts")]
        public virtual async Task<IReadOnlyList<ProductDto>> GetAllProducts()
        {
            var pagedata = await GetListAsync(new PagedAndSortedResultRequestDto { Sorting = "No", MaxResultCount = 100 });
            return pagedata.Items;
        }
    }
}
